<?php
/**
 * Created by PhpStorm.
 * User: zgh
 * Date: 2021-07-20
 * Time: 9:36
 */

namespace app\admin\validate;


use app\common\model\MenuModel;
use think\Validate;

class MenuValidate extends Validate
{
    const SCENE_DEL = 'del';

    protected $rule = [
        'title|菜单名称' => 'require|max:25',
        'del_ids|ID' => "checkDelIds"
    ];


    protected $scene = [
        'del' => ['del_ids'],
    ];

    protected function checkDelIds($value, $rule, $data)
    {
        if (MenuModel::where(["is_index" => "1"])->where([["id", "in", $value]])->find()) {
            return "后台首页不能删除";
        }
        return true;
    }

}